<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:m="http://www.ol4jsf.org"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:o="http://openfaces.org/"
	template="/WEB-INF/esquema/plantillasimple.xhtml">

	<ui:define name="body">
		<h:form>
			<div align="center">
				<strong>#{messages['spatial_rules.TITLE']}</strong>
				<br />
				<rich:separator lineType="solid"/>
				<br />
				<br />
				
				<a4j:commandLink
					value="#{messages['spatial_rules.new_rule']}"
					action="#{spatialRulesHelper.newSpatialRule}"
					reRender="editRulesPanel"
					oncomplete="#{rich:component('editRulesPanel')}.show();">
				</a4j:commandLink>
				
				<br />
				<br />
				
				<rich:dataTable id="dtSpatialRules" value="#{spatialRulesHelper.spatialRules}" var="sr" width="95%">
					<f:facet name="header">
						<rich:columnGroup>
							<rich:column rowspan="2">
								#{messages['spatial_rules.code']}
							</rich:column>
							<rich:column rowspan="2">
								#{messages['spatial_rules.description']}
							</rich:column>
							<rich:column colspan="2">
								#{messages['spatial_rules.operand']} 1
							</rich:column>
							<rich:column rowspan="2">
								#{messages['spatial_rules.rule_operator']}
							</rich:column>
							<rich:column colspan="2">
								#{messages['spatial_rules.operand']} 2
							</rich:column>
							<rich:column colspan="2">
								#{messages['spatial_rules.distance_parameters']}
							</rich:column>
							<rich:column rowspan="2">
								#{messages['spatial_rules.action']}
							</rich:column>
							<rich:column rowspan="2">
							</rich:column>
							
							<rich:column breakBefore="true">
								#{messages['spatial_rules.level']}
							</rich:column>
							<rich:column>
								#{messages['spatial_rules.use']}
							</rich:column>
							<rich:column>
								#{messages['spatial_rules.level']}
							</rich:column>
							<rich:column>
								#{messages['spatial_rules.use']}
							</rich:column>
							<rich:column>
								#{messages['spatial_rules.distance_comparison_operator']}
							</rich:column>
							<rich:column>
								#{messages['spatial_rules.distance_distance']}
							</rich:column>
						</rich:columnGroup>
					</f:facet>
					
					<rich:column>
						<h:outputText value="#{sr.code}" />
					</rich:column>
					<rich:column>
						<h:outputText value="#{sr.description}" />
					</rich:column>
					<rich:column>
						<h:outputText value="#{sr.levelOperand1.name}" />
					</rich:column>
					<rich:column>
						<h:outputText value="#{sr.landUseOperand1.completeCode} - #{sr.landUseOperand1.name}" />
					</rich:column>
					<rich:column>
						<h:outputText value="#{messages[sr.ruleOperator.name()]}" />
					</rich:column>
					<rich:column>
						<h:outputText value="#{sr.levelOperand2.name}" />
					</rich:column>
					<rich:column>
						<h:outputText value="#{sr.landUseOperand2.completeCode} - #{sr.landUseOperand2.name}" />
					</rich:column>
					<rich:column>
						<h:outputText value="#{messages[sr.comparisonOperator.name()]}" />
					</rich:column>
					<rich:column>
						<h:outputText value="#{sr.comparisonParameterValue}" />
					</rich:column>
					<rich:column>
						<h:outputText value="#{messages[sr.action.name()]}" />
					</rich:column>
					<rich:column style="text-align:center;">
						<a4j:commandLink
							value="Editar"
							action="#{spatialRulesHelper.editSpatialRule(sr)}"
							reRender="editRulesPanel"
							oncomplete="#{rich:component('editRulesPanel')}.show();">
						</a4j:commandLink>
						#{'  '}
						<a4j:commandLink
							value="#{messages['button.delete']}"
							action="#{spatialRulesHelper.deleteSpatialRule(sr)}"
							reRender="dtSpatialRules">
							<o:confirmation
								message="#{messages['msg.delete_record']}. #{messages['button.continue']}?"
								caption="SIGIT"
								details=""
								okButtonText="#{messages['button.ok']}"
								cancelButtonText="#{messages['button.cancel']}">
							</o:confirmation>
						</a4j:commandLink>
					</rich:column>
				</rich:dataTable>
			</div>
		</h:form>
		
		<ui:include src="/permits/editSpatialRules.xhtml" />
	</ui:define>
	

</ui:composition>

